package jdbc;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class Mysq {
    static Properties root = new Properties();
    public static void main(String[] args) {
        String url ="jdbc:mysql://localhost:3306/xxyf";
        String user = "root";
        String password = "root";


        try {
            root.load(new FileInputStream("D:\\git_warehouse\\JAVA\\untitled2\\src\\jdbc\\config1.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            System.out.println("连接成功");

            System.out.println("1");

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try (Connection conne = DriverManager.getConnection(url,root)){
            System.out.println("数据库连接成功:"+conne);
        }catch (SQLException e){
            e.getErrorCode();

        }
    }

}
